package net.coding.api.test;

import org.junit.runner.Description;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;

public class ApiTestRunner extends BlockJUnit4ClassRunner {

    public ApiTestRunner(Class<?> klass) throws InitializationError {
        super(klass);
    }

    @Override
    protected Description describeChild(FrameworkMethod method) {
        Api api = method.getAnnotation(Api.class);
        if (api == null) {
            return super.describeChild(method);
        }
        String name = String.format("%s", method.getName());
        return Description.createTestDescription(getTestClass().getJavaClass(), name, method.getAnnotations());
    }
}
